#include<iostream>
using namespace std;
const int N = 110;
char a[N][N];
char c[N][N];
int b[N * N];
int n;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
			if (i != 1 && i != n && j != 1 && j != n) {
				c[i][j] = a[i][j];
			}
			//cout << a[i][j] << " ";
		}
	}
	char temp1 = a[1][1];
	char temp2 = a[1][n];
	char temp3 = a[n][n];
	char temp4 = a[n][1];
	for (int i = n; i >= 2; i--) {
		c[1][i] = a[1][i - 1];
	}
	//c[1][n] = a[1][n];
	for (int i = n; i >= 2; i--) {
		c[i][n] = a[i - 1][n];
	}
	
	for (int i = 1; i <= n - 1; i++) {
		c[n][i] = a[n][i + 1];
	}
	for (int i = 1; i <= n - 1; i++) {
		c[i][1] = a[i + 1][1];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cout << c[i][j];
		}
		cout << endl;
	}
	///*int cnt = 0;
	//for (int i = 1; i <= n; i++) {
	//	for (int j = 1; j <= n; i++) {
	//		if (i == 1 || j == 1) {
	//			b[++cnt] = a[i][j] + '0';
	//		}
	//	}
	//}*/
	//for (int i = 1; i <= cnt; i++) {
	//	cout << b[i] << " ";
	//}
	return 0;
}